package com.innovations.inn.service.impl;

import java.util.List;

import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.ResearchOutcomesRepliesMapper;
import com.innovations.inn.domain.ResearchOutcomesReplies;
import com.innovations.inn.service.IResearchOutcomesRepliesService;

/**
 * 科研成果评价回复Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class ResearchOutcomesRepliesServiceImpl implements IResearchOutcomesRepliesService 
{
    @Autowired
    private ResearchOutcomesRepliesMapper researchOutcomesRepliesMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询科研成果评价回复
     * 
     * @param repliesId 科研成果评价回复主键
     * @return 科研成果评价回复
     */
    @Override
    public ResearchOutcomesReplies selectResearchOutcomesRepliesByRepliesId(Long repliesId)
    {
        return researchOutcomesRepliesMapper.selectResearchOutcomesRepliesByRepliesId(repliesId);
    }

    /**
     * 查询科研成果评价回复列表
     * 
     * @param researchOutcomesReplies 科研成果评价回复
     * @return 科研成果评价回复
     */
    @Override
    public List<ResearchOutcomesReplies> selectResearchOutcomesRepliesList(ResearchOutcomesReplies researchOutcomesReplies)
    {
        return researchOutcomesRepliesMapper.selectResearchOutcomesRepliesList(researchOutcomesReplies);
    }

    /**
     * 新增科研成果评价回复
     * 
     * @param researchOutcomesReplies 科研成果评价回复
     * @return 结果
     */
    @Override
    public int insertResearchOutcomesReplies(ResearchOutcomesReplies researchOutcomesReplies)
    {
        return researchOutcomesRepliesMapper.insertResearchOutcomesReplies(researchOutcomesReplies);
    }

    /**
     * 修改科研成果评价回复
     * 
     * @param researchOutcomesReplies 科研成果评价回复
     * @return 结果
     */
    @Override
    public int updateResearchOutcomesReplies(ResearchOutcomesReplies researchOutcomesReplies)
    {
        return researchOutcomesRepliesMapper.updateResearchOutcomesReplies(researchOutcomesReplies);
    }

    /**
     * 批量删除科研成果评价回复
     * 
     * @param repliesIds 需要删除的科研成果评价回复主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesRepliesByRepliesIds(Long[] repliesIds)
    {
        return researchOutcomesRepliesMapper.deleteResearchOutcomesRepliesByRepliesIds(repliesIds);
    }

    /**
     * 删除科研成果评价回复信息
     * 
     * @param repliesId 科研成果评价回复主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesRepliesByRepliesId(Long repliesId)
    {
        return researchOutcomesRepliesMapper.deleteResearchOutcomesRepliesByRepliesId(repliesId);
    }

    /**
     * 实体数据补全
     *
     * @param researchOutcomesReplies 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(ResearchOutcomesReplies researchOutcomesReplies, Long userId, Integer crateType) {
        //主键
        if (researchOutcomesReplies.getRepliesId() == null || "".equals(researchOutcomesReplies.getRepliesId())) {
            researchOutcomesReplies.setRepliesId(idGeneratorSnowflake.nextId());
        }
//        //创建人、创建时间
//        if (crateType == 1) {
//            if (researchOutcomesReplies.getCreateBy() == null || "".equals(researchOutcomesReplies.getCreateBy())) {
//                researchOutcomesReplies.setCreateBy(userId);
//            }
//            if (researchOutcomesReplies.getCreateTime() == null) {
//                researchOutcomesReplies.setCreateTime(DateUtils.getNowDate());
//            }
//        }
//        //修改人
//        if (researchOutcomesReplies.getModifyBy() == null) {
//            researchOutcomesReplies.setModifyBy(userId);
//        }
//        //修改时间
//        if (researchOutcomesReplies.getModifyTime() == null) {
//            researchOutcomesReplies.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
